package cn.tedu.spring.eg3;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
public class ShopController {
    private String name;

    public ShopController() {
        System.out.println("1.通过无参构造实例化");
    }

    @Value("小明")
    public void setName(String name) {
        this.name = name;
        System.out.println("2.通过set方法赋值");
    }
    @PostConstruct
    public void show() {
        System.out.println("3.@PostConstruct注解在bean创建之前执行，此时bean还没有被创建");
    }
    @PreDestroy
    public void end() {
        System.out.println("5.@PreDestroy在ban销毁之前执行");
    }
}
